﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows.Forms;
using DevComponents.DotNetBar.Controls;
using DevComponents.DotNetBar;
using DevComponents.Editors.DateTimeAdv;
using QLTB.Controllers;
using QuanLyThietBi.Manager;
using QuanLyThietBi.ManagerBase;
using QuanLyThietBi.Entity;


namespace QLTB.Controllers
{
   public class TBL_LoaiThietBiCtrl
    {

        public void HienthiDGV(DataGridViewX DGV, BindingNavigator BN)
        {
            BindingSource BS = new BindingSource();
            BS.DataSource = TBL_LoaiThietBiManager.CreateInstant().LayDanhSachLoaiThietBi();
            BN.BindingSource = BS;
            DGV.DataSource = BS;
        }
        // Them moi loai thiet bi
        public void ThemMoiLoaiTB(string MaLoaiTB, string TenLoaiTB, string Mota)
        {
            TBL_LoaiThietBiEntity objLoaiThietBi = new TBL_LoaiThietBiEntity();
            objLoaiThietBi.MaLoaiTB = MaLoaiTB;
            objLoaiThietBi.TenLoaiTB = TenLoaiTB;
            objLoaiThietBi.MoTa = Mota;
            TBL_LoaiThietBiManager.CreateInstant().Insert(objLoaiThietBi);

        }

        //Cap nhat thong tin loai thiet bi
        public void CapNhatLoaiTB(string MaLoaiTB, string TenLoaiTB, string Mota)
        {
            TBL_LoaiThietBiEntity objLoaiThietBi = new TBL_LoaiThietBiEntity();
            objLoaiThietBi.MaLoaiTB = MaLoaiTB;
            objLoaiThietBi.TenLoaiTB = TenLoaiTB;
            objLoaiThietBi.MoTa = Mota;
            TBL_LoaiThietBiManager.CreateInstant().Update(objLoaiThietBi);

        }


        // Xoa dong loai thiet bi
        public void XoaLoaiTB(string sMaLoaiTB)
        {

            TBL_LoaiThietBiManager.CreateInstant().DeleteByMaLoaiTB(sMaLoaiTB);
            
        }

    }
}
